import axios from "@/utils/http";
//数据
const state = {
  //数据定义处
  tableData:[],
  tableTotal:1,

};

const getters = {
  getRegData(state:any){
    return state.tableData
  },
};

const mutations = {
  //修改数据处 ，可在这写axios请求拿数据
  setRegData(state:any,page:any){
    axios({
      url:"/seeDoctor/register/queryRegisters",
      method:"get",
      params:{
        CurrentPage:page.currentPage,
        PageSize:page.pageSize
      }
      }).then((res:any)=>{
          console.log("全部数据",res);
          state.tableData=res.data.data
          state.tableTotal=res.data.count
     }).catch(err=>{
      console.log(err);
     })
    
  },


  // 搜索数据接口
  searchRegData(state:any,data:any){
    axios({
      url:"/seeDoctor/register/queryRegister",
      method:"get",
      params:{
        bankName:data.bankName,
        stateType:data.stateType,
        startTime:"2023-02-01 00:00:00",
        // startTime:"2023-02-01 14:23:16",
        endTime:data.endTime,
        CurrentPage:data.currentPage,
        PageSize:data.pageSize
      }
      }).then((res:any)=>{
          console.log("搜索数据",res.data);
          state.tableData=res.data.data
        state.tableTotal=1
     }).catch(err=>{
      console.log(err);
     })
  },

  // 退费接口
  refundReg(state:any){
    axios({
      url:"/refund",
      method:"post",
      params:{
        message:"何",
        orderId:666,
        price:1000,
        tradeType:1
      }
      }).then((res:any)=>{
          console.log("退费",res.data);
          
     }).catch(err=>{
      console.log(err);
     })
  },

  // 退号接口
  cancelRegNum(state:any,data:any){
    axios({
      url:"/seeDoctor/register/updateRegister",
      method:"post",
      params:{
        id:data.id,
        refundInfo:"退款说明"
      }
      }).then((res:any)=>{
          console.log("退号",res.data);
          
     }).catch(err=>{
      console.log(err);
     })
  },
  // 作废接口
  wasteRegNum(state:any,data:any){
    axios({
      url:"/seeDoctor/register/deleteRegister",
      method:"post",
      params:{
        id:data.id
      }
      }).then((res:any)=>{
          console.log("作废",res.data);
          
     }).catch(err=>{
      console.log(err);
     })
  }

};



const actions = {};

export default {
  state,
  mutations,
  actions,
  getters,
};
